def test_if_there_are_non_numerical_asteroids(resonancesfixture): ASTEROIDS_NUMBER_IN_RESONANCESFIXTURE = 6 planets = ('JUPITER', 'SATURN') line_data_set = [ '1 1 1 0 0 -3 4.1509'.split(), '1 2 2 0 0 -5 3.5083'.split() ] fixture_base(('2004A111', ), (planets, ), line_data_set) assert len([x for x in get_resonances(1, 10 ** 5, False, planets)])\ == ASTEROIDS_NUMBER_IN_RESONANCESFIXTURE
def test_asteroid_numbers(resonancesfixture, start: int, stop: int, fixture_indexes: Tuple[int]): asteroid_nums, planets = resonancesfixture counter = 0 for resonance in get_resonances(start, stop, False, planets): assert resonance.asteroid_number == asteroid_nums[ fixture_indexes[counter]] counter += 1 assert counter == len(fixture_indexes)
def clear_phases(start: int, stop: int, planets: Tuple[str]): conn = engine.connect() resonance_ids = [] redis_logged = False for resonance in get_resonances(start, stop, False, planets): try: REDIS.delete('%s:%i' % (TABLENAME, resonance.id)) except ConnectionError: redis_logged = _log_redis(redis_logged) resonance_ids.append(str(resonance.id)) filename = get_file_name(resonance.id) if os.path.exists(filename): os.remove(filename) conn.execute("DELETE FROM %s WHERE resonance_id = ANY('{%s}'::int[]);" % (TABLENAME, ','.join(resonance_ids)))
def test_only_librations(only_librations, resonance_count, resonance_fixture_different_librations): asteroid_nums, planets, libration = resonance_fixture_different_librations assert len([x for x in get_resonances(1, 10**5, only_librations, planets) ]) == resonance_count
def test_planets(resonance_fixture_different_planets): asteroid_nums, planets = resonance_fixture_different_planets for resonance in get_resonances(1, 10**5, False, planets): for body, planet in zip(resonance.get_big_bodies(), planets): assert body.name == planet
def test_ordering(resonancesfixture): asteroid_nums, planets = resonancesfixture max_asteroid_num = 0 for resonance in get_resonances(1, 10**5, False, planets): assert resonance.asteroid_number >= max_asteroid_num