예제 #1
0
def _provide_current_station(station_name=None, branch_name=None):
    if not station_name:
        station_name = get_hostname()
    store = new_store()
    if branch_name:
        branch = store.find(
            Person,
            And(Person.name == branch_name,
                Branch.person_id == Person.id)).one()
    else:
        branches = store.find(Branch)
        if branches.count() == 0:
            person = Person(name=u"test", store=store)
            branch = Branch(person=person, store=store)
        else:
            branch = branches[0]

    provide_utility(ICurrentBranch, branch)

    station = BranchStation.get_station(store, branch, station_name)
    if not station:
        station = BranchStation.create(store, branch, station_name)

    assert station
    assert station.is_active

    provide_utility(ICurrentBranchStation, station)
    store.commit(close=True)
예제 #2
0
def _provide_current_station(station_name=None, branch_name=None):
    if not station_name:
        station_name = get_hostname()
    store = new_store()
    if branch_name:
        branch = store.find(Person,
                            And(Person.name == branch_name,
                                Branch.person_id == Person.id)).one()
    else:
        branches = store.find(Branch)
        if branches.count() == 0:
            person = Person(name=u"test", store=store)
            branch = Branch(person=person, store=store)
        else:
            branch = branches[0]

    provide_utility(ICurrentBranch, branch)

    station = BranchStation.get_station(store, branch, station_name)
    if not station:
        station = BranchStation.create(store, branch, station_name)

    assert station
    assert station.is_active

    provide_utility(ICurrentBranchStation, station)
    store.commit(close=True)
예제 #3
0
 def test_get_station(self):
     with self.assertRaisesRegexp(
         TypeError, ur"BranchStation.get_station\(\) requires a Branch"):
         BranchStation.get_station(self.store, None, None)
예제 #4
0
 def test_get_station(self):
     with self.assertRaisesRegex(
             TypeError, r"BranchStation.get_station\(\) requires a Branch"):
         BranchStation.get_station(self.store, None, None)