Exemplo n.º 1
0
 def test_shortest_path_maar_gan_falasmaryon(self):
     traveler = Traveler()
     expected_travel_route = [
         City.MAAR_GAN, City.ALD_RUHN, City.CALDERA, Stronghold.FALASMARYON
     ]
     assert traveler.find_shortest_path(
         City.MAAR_GAN, Stronghold.FALASMARYON) == expected_travel_route
Exemplo n.º 2
0
 def test_shortest_path_gnisis_molag_mar(self):
     traveler = Traveler()
     expected_travel_route = [
         City.GNISIS, City.SEYDA_NEEN, City.VIVEC, City.MOLAG_MAR
     ]
     expected_travel_route_2 = [
         City.GNISIS, City.ALD_RUHN, City.VIVEC, City.MOLAG_MAR
     ]
     route = traveler.find_shortest_path(City.GNISIS, City.MOLAG_MAR)
     assert route == expected_travel_route or route == expected_travel_route_2
Exemplo n.º 3
0
def test_time_travelers_clock_ticks_away_at_the_life_of_the_traveler():
    traveler_1 = Traveler()
    traveler_2 = Traveler()
    traveler_2.increase_speed(200 * 1000)

    assert traveler_1.age == traveler_2.age and traveler_1.age == 0

    traveler_1.clock()
    traveler_2.clock()

    assert traveler_1.age == 1
    assert traveler_2.age == 0.8
Exemplo n.º 4
0
def test_time_travelers_time_rate_changes_with_speed():
    traveler = Traveler()
    traveler.increase_speed(200)
    assert traveler.universal_time_speed == 1.001
    traveler.increase_speed(200)
    assert traveler.universal_time_speed == 1.002
    traveler.increase_speed(-200)
    assert traveler.universal_time_speed == 1.001
Exemplo n.º 5
0
def test_time_traveler_travels_to_diff_year():
    traveler = Traveler()
    assert traveler.current_year == 2019
    traveler.change_year(5)
    assert traveler.current_year == 2024
    traveler.change_year(-2)
    assert traveler.current_year == 2022
Exemplo n.º 6
0
 def test_shortest_path_gnisis_seyda_neen(self):
     traveler = Traveler()
     expected_travel_route = [City.GNISIS, City.SEYDA_NEEN]
     assert traveler.find_shortest_path(
         City.GNISIS, City.SEYDA_NEEN) == expected_travel_route
Exemplo n.º 7
0
 def test_shortest_path_khuul_ald_ruhn(self):
     traveler = Traveler()
     expected_travel_route = [City.KHUUL, City.ALD_RUHN]
     assert traveler.find_shortest_path(
         City.KHUUL, City.ALD_RUHN) == expected_travel_route
Exemplo n.º 8
0
 def test_balmora_maar_gan_route(self):
     traveler = Traveler()
     expected_travel_route = [City.BALMORA, City.ALD_RUHN, City.MAAR_GAN]
     assert traveler.find_shortest_path(
         City.BALMORA, City.MAAR_GAN) == expected_travel_route
Exemplo n.º 9
0
 def test_balmora_maar_gan_connected(self):
     traveler = Traveler()
     ret_val = traveler.are_connected(City.BALMORA, City.MAAR_GAN)
     assert ret_val
Exemplo n.º 10
0
 def test_ald_ruhn_vivec_not_directly_connected(self):
     traveler = Traveler()
     assert not traveler.are_directly_connected(City.ALD_RUHN, City.VIVEC)
Exemplo n.º 11
0
#!/usr/bin/env python

# Author: Klaus Klokmose Nielsen
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

from traveler import Traveler
from authentication import Authentication
import socket

Travellers = {
    42: Traveler(42, "Cem Turan", None),
    43: Traveler(43, "Klaus Klokmose Nielsen", None)
}
AccessTokens = {
    'testToken1234': Authentication(42, 'testToken1234'),
    'testToken5678': Authentication(43, 'testToken5678')
}

PORT = 1337
HOST = "0.0.0.0"


def me(uid):
    if uid in Travellers:
        return Travellers[uid].__dict__
    else:
        return None


def checkIn(uid, sid):
    return {'CheckedIn': Travellers[uid].checkIn(sid)}
Exemplo n.º 12
0
    def get_nearby_travelers(self, traveler):
        return [traveler2 for traveler2 in self.travelers if self.carpool_match(traveler, traveler2)]

    def carpool_match(self, traveler1, traveler2): 
        if traveler1 is traveler2: return False
        distance = vincenty(traveler1.geolocation, traveler2.geolocation)
        return distance.miles < self.acceptable_miles_away(traveler1)

    def acceptable_miles_away(self, traveler):
        traveler_to_destination_distance = vincenty(traveler.geolocation, self.destination).miles
        return max(self.min_distance, self.relative_distance_percent * traveler_to_destination_distance)


if __name__ == '__main__':
    ohio_union = (39.997794, -83.008511)
    adam_from_france = Traveler(46.333423, 2.798206)
    face_from_columbus = Traveler(39.960956, -82.994692)
    dave_from_columbus = Traveler(39.961589, -82.992026)
    bill_from_des_moines = Traveler(41.554605, -93.636682)
    susy_from_des_moines = Traveler(41.554854, -93.634928)

    test_travelers = [adam_from_france, face_from_columbus, dave_from_columbus,
                      bill_from_des_moines, susy_from_des_moines]

    matcher = CarpoolMatcher(ohio_union, test_travelers)
    carpool_groups = matcher.make_groups()
    
    assert carpool_groups[adam_from_france] == []
    assert carpool_groups[face_from_columbus] == [dave_from_columbus]
    assert carpool_groups[bill_from_des_moines] == [susy_from_des_moines]
Exemplo n.º 13
0
def test_time_traveler_can_change_speed():
    traveler = Traveler()
    traveler.increase_speed(2)
    assert traveler.speed == 2
Exemplo n.º 14
0
def test_time_traveler_has_time_rate():
    traveler = Traveler()
    assert traveler.universal_time_speed == 1.0
Exemplo n.º 15
0
 def test_balmora_maar_gan_not_directly_connected(self):
     traveler = Traveler()
     assert not traveler.are_directly_connected(City.BALMORA, City.MAAR_GAN)
Exemplo n.º 16
0
 def test_balmora_ald_ruhn_directly_connected(self):
     traveler = Traveler()
     assert traveler.are_directly_connected(City.BALMORA, City.ALD_RUHN)
Exemplo n.º 17
0
'''
   Directives and roles for Legal Resource Registry
'''

import re, sys

from docutils import nodes, statemachine
from docutils.parsers.rst import directives, Directive
from utils import Utils
from traveler import Traveler
from nodes import *

from manual import FloaterDirective

traveler = Traveler()


class TabDirective(Directive):
    required_arguments = 1
    optional_arguments = 0
    final_argument_whitespace = True
    has_content = False
    option_spec = {
        'url': directives.unchanged,
        'selected': directives.unchanged
    }

    def run(self):
        node = tab(self.block_text, self.arguments[0])
        if self.options.has_key('url'):
            node['href'] = self.options['url']