Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many small issues #1342

Merged
merged 6 commits into from
Dec 13, 2024

fix #1334 fail send when len_written == 0

3a355e6
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

Many small issues #1342

fix #1334 fail send when len_written == 0
3a355e6
Select commit
Loading
Failed to load commit list.
GitHub Actions / Test Results failed Dec 13, 2024 in 0s

4 fail, 3 skipped, 231 pass in 1m 29s

238 tests  ±0   231 ✅  - 1   1m 29s ⏱️ -6s
  1 suites ±0     3 💤 ±0 
  1 files   ±0     4 ❌ +1 

Results for commit 3a355e6. ± Comparison against earlier commit 458858d.

Annotations

Check warning on line 0 in sarracenia.__init___test.Test_Message

See this annotation in the file changed.

@github-actions github-actions / Test Results

test_fromFileInfo (sarracenia.__init___test.Test_Message) failed

tests/junit/test-results.xml [took 0s]
Raw output
Failed: DID NOT RAISE <class 'KeyError'>
self = <__init___test.Test_Message object at 0x7f7339334070>
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/test_fromFileInfo0')

    def test_fromFileInfo(self, tmp_path):
        # Set 1
        path = str(tmp_path) + os.sep + "file1.txt"
        open(path, 'a').close()
        options = sarracenia.config.default_config()
    
        msg = sarracenia.Message.fromFileInfo(path, options, None)
        assert msg['_format'] == 'v03'
        assert len(msg['_deleteOnPost']) == 10
        assert msg['local_offset'] == 0
    
        # Set 2
        path = str(tmp_path) + os.sep + "file2.txt"
        open(path, 'a').close()
        options = sarracenia.config.default_config()
        options.permCopy = True
        options.timeCopy = False
        options.to_clusters = "to_clusters"
        options.cluster = "from_cluster"
        options.source = "source"
        options.identity_method = ''
        delattr(options, 'post_format')
        msg = sarracenia.Message.fromFileInfo(path, options, os.lstat(path))
        assert msg['to_clusters'] == 'to_clusters'
        assert msg['from_cluster'] == 'from_cluster'
        assert msg['source'] == 'source'
        assert msg['_format'] == 'v03'
    
        # Set 3
        options = sarracenia.config.default_config()
        options.strip = 1
        options.identity_method = 'random'
        options.post_format = 'post_format'
        options.exchange = ''
        options.post_exchange = 'post_exchange'
        msg = sarracenia.Message.fromFileInfo(str(tmp_path), options, os.lstat(tmp_path))
        assert msg['rename'] == os.sep + os.path.relpath(tmp_path, '/tmp')
        assert msg['_format'] == 'post_format'
        assert msg['exchange'] == 'post_exchange'
        assert msg['identity']['method'] == 'random'
    
        # Set 4
        path = str(tmp_path) + os.sep + "file4.txt"
        open(path, 'a').close()
        options = sarracenia.config.default_config()
        options.strip = 20
        options.identity_method = 'cod,identityValue'
        delattr(options, 'post_format')
        options.post_topicPrefix = ['v02']
        msg = sarracenia.Message.fromFileInfo(path, options, os.lstat(path))
        assert msg['rename'] == "/"
        assert msg['_format'] == "v02"
        assert msg['identity'] == {'method': 'cod', 'value': 'identityValue' }
    
        #Set 5
        path = str(tmp_path) + os.sep + "file5.txt"
        open(path, 'a').close()
        options = sarracenia.config.default_config()
        options.rename = str(tmp_path) + os.sep + "file4a.txt"
>       with pytest.raises(KeyError):
E       Failed: DID NOT RAISE <class 'KeyError'>

tests/sarracenia/__init___test.py:325: Failed

Check warning on line 0 in sarracenia.config_test

See this annotation in the file changed.

@github-actions github-actions / Test Results

test_subscription (sarracenia.config_test) failed

tests/junit/test-results.xml [took 0s]
Raw output
AssertionError: assert 2 == 1
 +  where 2 = len([{'broker': <sarracenia.config.credentials.Credential object at 0x7f73196e92a0>, 'bindings': [{'exchange': 'hoho1', 'p...ernal.cloudapp.net_81520592', 'cleanup_needed': None, 'durable': True, 'prefetch': 25, 'bind': True, 'declare': True}}])
 +    where [{'broker': <sarracenia.config.credentials.Credential object at 0x7f73196e92a0>, 'bindings': [{'exchange': 'hoho1', 'p...ernal.cloudapp.net_81520592', 'cleanup_needed': None, 'durable': True, 'prefetch': 25, 'bind': True, 'declare': True}}] = <sarracenia.config.Config object at 0x7f73196e9210>.subscriptions
def test_subscription():
    
         o = copy.deepcopy(sarracenia.config.default_config())
    
         o.component = 'subscribe'
         o.config = 'ex1'
         o.action = 'start'
         o.no = 1
         before_add=len(o.credentials.credentials)
         o.credentials.add( 'amqp://lapinferoce:etpoilu@localhost' )
         o.credentials.add( 'amqp://capelli:tropcuit@localhost' )
         o.parse_line( o.component, o.config, "subscribe/ex1", 1, "broker amqp://lapinferoce@localhost" )
         o.parse_line( o.component, o.config, "subscribe/ex1", 2, "exchange hoho1" )
    
         assert( o.exchange == "hoho1" )
    
         o.parse_line( o.component, o.config, "subscribe/ex1", 3, "subtopic hoho.#" )
         o.parse_line( o.component, o.config, "subscribe/ex1", 3, "subtopic lala.hoho.#" )
    
         assert( hasattr(o,'subscriptions')  )
>        assert( len(o.subscriptions)==1 )
E        AssertionError: assert 2 == 1
E         +  where 2 = len([{'broker': <sarracenia.config.credentials.Credential object at 0x7f73196e92a0>, 'bindings': [{'exchange': 'hoho1', 'p...ernal.cloudapp.net_81520592', 'cleanup_needed': None, 'durable': True, 'prefetch': 25, 'bind': True, 'declare': True}}])
E         +    where [{'broker': <sarracenia.config.credentials.Credential object at 0x7f73196e92a0>, 'bindings': [{'exchange': 'hoho1', 'p...ernal.cloudapp.net_81520592', 'cleanup_needed': None, 'durable': True, 'prefetch': 25, 'bind': True, 'declare': True}}] = <sarracenia.config.Config object at 0x7f73196e9210>.subscriptions

tests/sarracenia/config_test.py:336: AssertionError

Check warning on line 0 in sarracenia.flowcb.filter.geometry_test

See this annotation in the file changed.

@github-actions github-actions / Test Results

test_after_accept (sarracenia.flowcb.filter.geometry_test) failed

tests/junit/test-results.xml [took 0s]
Raw output
assert 1 == 2
 +  where 1 = len([{'_format': 'v03', '_deleteOnPost': {'_format'}, 'new_file': '/foo/bar/NewFile.txt', 'new_dir': '/foo/bar', 'geometry': '{"type": "Point", "coordinates": [-76, 39.284]}'}])
 +    where [{'_format': 'v03', '_deleteOnPost': {'_format'}, 'new_file': '/foo/bar/NewFile.txt', 'new_dir': '/foo/bar', 'geometry': '{"type": "Point", "coordinates": [-76, 39.284]}'}] = namespace(ok=[], incoming=[{'_format': 'v03', '_deleteOnPost': {'_format'}, 'new_file': '/foo/bar/NewFile.txt', 'new_d...wFile.txt', 'new_dir': '/foo/bar', 'geometry': '{"type": "LineString", "coordinates": [93, 100]}'}], directories_ok=[]).rejected
def test_after_accept():
        options = sarracenia.config.default_config()
        options.logLevel = 'DEBUG'
    
        # Testing when the config is a polygon
        options.geometry = [features['poly1']]
        geojson = sarracenia.flowcb.filter.geometry.Geometry(options)
    
        worklist = make_worklist()
        #accepted
        worklist.incoming.append(make_message("poly2"))
        worklist.incoming.append(make_message("pointA"))
        #rejected
        worklist.incoming.append(make_message("poly3"))
        worklist.incoming.append(make_message("pointB"))
        #failed
        worklist.incoming.append(make_message("line1"))
    
        geojson.after_accept(worklist)
>       assert len(worklist.rejected) == 2
E       assert 1 == 2
E        +  where 1 = len([{'_format': 'v03', '_deleteOnPost': {'_format'}, 'new_file': '/foo/bar/NewFile.txt', 'new_dir': '/foo/bar', 'geometry': '{"type": "Point", "coordinates": [-76, 39.284]}'}])
E        +    where [{'_format': 'v03', '_deleteOnPost': {'_format'}, 'new_file': '/foo/bar/NewFile.txt', 'new_dir': '/foo/bar', 'geometry': '{"type": "Point", "coordinates": [-76, 39.284]}'}] = namespace(ok=[], incoming=[{'_format': 'v03', '_deleteOnPost': {'_format'}, 'new_file': '/foo/bar/NewFile.txt', 'new_d...wFile.txt', 'new_dir': '/foo/bar', 'geometry': '{"type": "LineString", "coordinates": [93, 100]}'}], directories_ok=[]).rejected

tests/sarracenia/flowcb/filter/geometry_test.py:100: AssertionError

Check warning on line 0 in sarracenia.flowcb.scheduled.__scheduled___test

See this annotation in the file changed.

@github-actions github-actions / Test Results

test_schedules (sarracenia.flowcb.scheduled.__scheduled___test) failed

tests/junit/test-results.xml [took 0s]
Raw output
assert 14220.0 == 7020
 +  where 14220.0 = <built-in method total_seconds of datetime.timedelta object at 0x7f73196e9230>()
 +    where <built-in method total_seconds of datetime.timedelta object at 0x7f73196e9230> = datetime.timedelta(seconds=14220).total_seconds
def test_schedules():
    
         options= build_options()
         options.scheduled_time=[ "12:40", "7:37" ]
    
         today=datetime.datetime.fromtimestamp(time.time(),datetime.timezone.utc)
         midnight=datetime.time(0,0,tzinfo=datetime.timezone.utc)
         midnight= datetime.datetime.combine(today,midnight)
    
    
         me=sarracenia.flowcb.scheduled.Scheduled(options)
         me.update_appointments(midnight)
         assert( len(me.appointments) == 2 )
    
         logger.info( f"set two appointments at specific times: {me.appointments=} {len(me.appointments)=}" )
         logger.info( f" {len(me.appointments)=}" )
    
    
         options = build_options()
         options.scheduled_hour= [ '1','3','5',' 7',' 9',' 13','21','23']
         options.scheduled_minute= [ '1,3,5',' 7',' 9',' 13',' 15',' 51','53' ]
    
         me=sarracenia.flowcb.scheduled.Scheduled(options)
         me.update_appointments(midnight)
    
         logger.info( f"set 72 appointments" )
         assert( len(me.appointments) == 72 )
    
         #logger.error( f" {me.appointments=} {len(me.appointments)=}" )
         #logger.error( f" HOHO {len(me.appointments)=}" )
    
         """
           this should work? but does not... dunno why... worth fixing but not part of #1206
    
           seems to barf on only having 1 scheduled hour... so maybe you need both?
         """
         #options = build_options()
         #options.scheduled_hour= [ '1' ]
         #options.scheduled_minute= []
         #me=sarracenia.flowcb.scheduled.Scheduled(options)
         #me.update_appointments(midnight)
         #assert( len(me.appointments) == 1 )
    
         #logger.error( f" {me.appointments=} {len(me.appointments)=}" )
         #logger.error( f" HOHO {len(me.appointments)=}" )
    
         """
             with both hour and minute specified... it works.
    
         """
         options = build_options()
         options.scheduled_hour= []
         options.scheduled_minute= []
         options.scheduled_time= []
         me=sarracenia.flowcb.scheduled.Scheduled(options)
         me.update_appointments(midnight)
    
         sample_time= datetime.time(hour=12, minute=5, tzinfo=datetime.timezone.utc )
         now=datetime.datetime.now(datetime.timezone.utc )
         sample_time= datetime.datetime.combine(now,sample_time)
    
         logger.info( f"default schedule (should be 300 second interval) {me.appointments=}" )
         assert( len(me.appointments) == 0 )
    
         me.calc_next_gather_time( sample_time )
         how_long = me.next_gather_time - sample_time
         logger.info( f" {how_long.total_seconds()=} until next poll. " )
         assert( how_long.total_seconds() <= 300 )
    
    
         logger.info( f"1 appointment at 01:01 each day..." )
         options = build_options()
         options = build_options()
         options.scheduled_hour= [ '1' ]
         options.scheduled_minute= [ '1' ]
         me=sarracenia.flowcb.scheduled.Scheduled(options)
         me.update_appointments(midnight)
         assert( len(me.appointments) == 1 )
    
         logger.info( f"pretending the time is 00:05 today" )
         sample_time= datetime.time(hour=0, minute=5, tzinfo=datetime.timezone.utc )
         now=datetime.datetime.now(datetime.timezone.utc )
         sample_time= datetime.datetime.combine(now,sample_time)
    
         me.calc_next_gather_time( sample_time )
         how_long = me.next_gather_time - sample_time
         logger.info( f" {how_long.total_seconds()=} until next poll. " )
         assert( how_long.total_seconds() == 3360 )
    
         options = build_options()
         options.scheduled_interval= [ 3600 ]
         options.scheduled_hour= [ ]
         options.scheduled_minute= [ ]
         me=sarracenia.flowcb.scheduled.Scheduled(options)
         me.update_appointments(midnight)
         assert( len(me.appointments) == 0 )
    
         logger.info( f"pretending the time is 00:05 today" )
         me.calc_next_gather_time( sample_time )
         how_long = me.next_gather_time - sample_time
         logger.info( f" {how_long.total_seconds()=} until next poll. " )
         assert( how_long.total_seconds() == 3600 )
    
         #logger.error( f" {me.appointments=} {len(me.appointments)=}" )
         #logger.error( f" HOHO {len(me.appointments)=}" )
    
         options.scheduled_hour= []
         options.scheduled_minute= []
         options.scheduled_time=[ "12:40", "7:37" ]
         me=sarracenia.flowcb.scheduled.Scheduled(options)
         me.update_appointments(midnight)
         assert( len(me.appointments) == 2 )
    
         logger.info( f"pretending the time is 00:05 today" )
         me.calc_next_gather_time( sample_time )
         how_long = me.next_gather_time - sample_time
         logger.info( f" {how_long.total_seconds()=} until next poll. " )
         assert( how_long.total_seconds() == 3600 )
    
    
         logger.info( f"Setting 4 appointments: 2:02, 4:02, 12:40, 7:37 ...")
         options= build_options()
         options.scheduled_hour= [ "2", "4" ]
         options.scheduled_minute= [ "2" ]
         options.scheduled_time=[ "12:40", "7:37" ]
         me=sarracenia.flowcb.scheduled.Scheduled(options)
         me.update_appointments(midnight)
    
         assert( len(me.appointments) == 4 )
    
         logger.info( f"pretending the time is 00:05 today" )
         me.calc_next_gather_time( sample_time )
         how_long = me.next_gather_time - sample_time
         logger.info( f" {how_long.total_seconds()=} until next poll. " )
>        assert( how_long.total_seconds() == 7020 )
E        assert 14220.0 == 7020
E         +  where 14220.0 = <built-in method total_seconds of datetime.timedelta object at 0x7f73196e9230>()
E         +    where <built-in method total_seconds of datetime.timedelta object at 0x7f73196e9230> = datetime.timedelta(seconds=14220).total_seconds

tests/sarracenia/flowcb/scheduled/__scheduled___test.py:159: AssertionError