Exemplo n.º 1
0
def test_remove_non_existing_centre():
    prov = Provider('*****@*****.**', '1234', 'McTester', 'Test',
                    '124024114', 'Official Tester')
    assert (prov.email == '*****@*****.**')
    assert (prov.centres == [])
    checker = prov.remove_centre('Randwick Hospital')
    assert (checker is False)
Exemplo n.º 2
0
def test_remove_existing_centre():
    prov = Provider('*****@*****.**', '1234', 'McTester', 'Test',
                    '124024114', 'Official Tester')
    assert (prov.centres == [])
    prov.add_centre('rand')
    assert ('rand' in prov.centres)
    checker = prov.remove_centre('RAnd')
    assert (checker == True)
    assert (prov.centres == [])
Exemplo n.º 3
0
def test_get_availability_for_existing_date():
    p = Provider('1', '1', '1', '', '', '')
    p.add_centre('rand')
    p.get_availability('rand', 2019, 9, 20)
    p.make_time_slot_unavailable('rand', 2019, 9, 20, '08:30')
    val = p.get_availability('rand', 2019, 9, 20)
    assert ('08:30' not in val and type(val) is list)
Exemplo n.º 4
0
def get_all_providers():
    providers = ProviderModel.query().fetch()
    list = []
    for providerModel in providers:
        provider = Provider()
        provider.id = providerModel.key.urlsafe()
        provider.providerName = providerModel.providerName
        provider.officialName = providerModel.officialName
        list.append(provider)

    return list
Exemplo n.º 5
0
def test_make_non_existing_and_available_slots_unavailable():
    p = Provider('1', '1', '1', '', '', '')
    p.add_centre('rand')
    p.get_availability('rand', 2019, 9, 20)
    checker = p.make_time_slot_unavailable('rand', 2019, 9, 20, '08:30')
    assert (checker == True)
    val = p.get_availability('rand', 2019, 9, 20)
    assert ('08:30' not in val)
    checker = p.make_time_slot_unavailable('rand', 2019, 9, 20, '09:30')
    val = p.get_availability('rand', 2019, 9, 20)
    assert ('08:30' not in val and '09:30' not in val)
Exemplo n.º 6
0
def test_getters():
    p = Provider('*****@*****.**', '1234', 'McTester', 'Test', '124024114',
                 'Official Tester')
    info = p.get_information()
    assert (info["email"] == '*****@*****.**'.lower())
    assert (info["password"] == '1234'.lower())
    assert (info["surname"] == 'McTester'.lower())
    assert (info["given_name"] == 'Test'.lower())
    assert (info["provider_no"] == '124024114'.lower())
    assert (info["service"] == 'Official Tester'.lower())
    assert (info["appointments"] == [])
    assert (info["centres"] == [])
    assert (info["availability"] == {})
    assert (info["rating"] == 0)
Exemplo n.º 7
0
def get_provider_by_id(provider_id):
    if not provider_id:
        return None

    provider_model = ndb.Key(urlsafe=provider_id).get()

    if not provider_model:
        logging.info("Invalid Identifier: " + provider_id)
        return None

    provider = Provider()
    provider.id = provider_model.key.id()
    provider.providerName = provider_model.providerName
    provider.officialName = provider_model.officialName
    return provider
Exemplo n.º 8
0
 def post(self):
     id = self['id']
     provider = Provider.get_by_id(long(id))
     owner = provider.owner.name if provider else ''
     phone = provider.phone_num if provider else ''
     self.write(json.dumps({'provider':{'owner':owner,'phone':phone}}),
                content_type = 'application/json')
Exemplo n.º 9
0
 def get(self):
     path = 'provider_details.html'
     provider = Provider.get_by_id(long(self['id']))
     appliance_id = self['appliance_id']
     appliance = Appliance.for_id(long(appliance_id)) if appliance_id else None
     store_name = appliance.store.name if appliance else ''
     schedule_repair_url = provider.schedule_repair_url
     schedule_repair_url = schedule_repair_url + '&appliance_id='+ appliance_id if appliance_id else schedule_repair_url
     template_values = {'details':provider.template_format,'name':provider.name, 'ratings':[x for x in range(1,6)], 'schedule_repair_url':schedule_repair_url, 'appliance_id':appliance_id, 'store_name':store_name}
     self.write(self.get_rendered_html(path, template_values), 200)
Exemplo n.º 10
0
 def get(self):
     path = 'provider_schedule_repair.html'
     provider = Provider.get_by_id(long(self['id']))
     appliance = Appliance.get_by_id(long(self['appliance_id']))
     details = [
         {
             'name':'provider',
             'title':'Provider',
             'value':provider.name,
             'id':provider.id,
             'readonly':'readonly'
         },
         {
             'name':'store',
             'title':'Store',
             'value':appliance.store.name,
             'readonly':'readonly'
         },
         {
             'name':'appliance',
             'title':'Appliance',
             'value':appliance.name,
             'readonly':'readonly'
         },
         {
             'name':'appliance_serial',
             'title':'Serial Number',
             'value':appliance.serial_num,
             'readonly':'readonly'
         },
         {
             'name':'appliance_manufacturer',
             'title':'Manufacturer',
             'value':appliance.manufacturer,
             'readonly':'readonly'
         },
         {
             'name':'fix_by',
             'value':'Select date (mm/dd/yy)',
             'title':'Fix by date',
             'type':'date',
             'readonly':''
         },
         {
             'name':'remarks',
             'value':'',
             'title':'Remarks',
             'readonly':''
         }
     ]
     priorities = ['Critical', 'Normal', 'Routine']
     template_values = {'details':details,'name':'New Work Order', 'ratings':[x for x in range(1,6)], 'priorities':priorities, 'appliance_id':self['appliance_id']}
     self.write(self.get_rendered_html(path, template_values), 200)
Exemplo n.º 11
0
 def load_manager_view(self, appliance_id):
     providers = [provider for provider in Provider.all().fetch(100)]
     path = "select_provider.html"
     markers = [[provider.name, provider.location.lat, provider.location.lon] for provider in providers]
     appliance = Appliance.for_id(long(appliance_id))
     store_name = appliance.store.name if appliance else ""
     template_values = {
         "providers": providers,
         "count": len(providers),
         "markers": markers,
         "appliance_id": appliance_id,
         "store_name": store_name,
     }
     self.write(self.get_rendered_html(path, template_values), 200)
Exemplo n.º 12
0
def get_work_orders_for_logged_in_user(self):
    email = self.session['email']
    workorders = []
    if is_store_login(self):
        appliances = []
        stores = Store.all().filter(self.session['role'] + ' =', email)
        for store in stores:
            appliances.extend([appliance.id for appliance in Appliance.all().filter('store =', store).fetch(100)])
        for appliance in appliances:
            workorders.extend([wo for wo in WorkOrder.all().filter('appliance =', str(appliance))])
    elif is_provider_login(self):
        providers = [p for p in Provider.all().fetch(100) if p.owner.key().name() == email]
        for provider in providers:
            workorders.extend([wo for wo in WorkOrder.all().filter('provider =', str(provider.key().id()))])
    return workorders
Exemplo n.º 13
0
 def add_provider_by_info(self,
                          email,
                          password,
                          surname,
                          given_name,
                          provider_no,
                          service,
                          specialist=False):
     if not any(provider.email == email.lower()
                for provider in self._providers):
         self._providers.append(
             Provider(email, password, surname, given_name, provider_no,
                      service, specialist))
         self.__add_provider_to_services(email.lower(), service.lower())
         return True  # Success, could instead return new provider object
     else:
         return False  # Failed (already in providers)
Exemplo n.º 14
0
 def get(self):
     path = "appliance_schedule_repair.html"
     appliance = Appliance.for_id(long(self["id"]))
     providers = Provider.all().fetch(100)
     provider_array = [(provider.id, provider.name) for provider in providers]
     details = [
         {"name": "appliance", "value": appliance.name, "id": appliance.id, "readonly": "readonly"},
         {"name": "provider", "value": "Choose Provider", "providers": provider_array, "readonly": ""},
         {"name": "provider_owner", "value": "Provider Owner", "readonly": "readonly"},
         {"name": "provider_phone", "value": "Provider Phone Number", "readonly": "readonly"},
         {"name": "fix_by", "value": "Fix by date", "type": "date", "readonly": ""},
         {"name": "remarks", "value": "Remarks", "readonly": ""},
     ]
     priorities = ["Critical", "Normal", "Routine"]
     template_values = {
         "details": details,
         "name": "New Work Order",
         "details_url": appliance.details_url,
         "priorities": priorities,
     }
     self.write(self.get_rendered_html(path, template_values), 200)
Exemplo n.º 15
0
def test_calc_average_rating_with_more_than_1_rating():
    p = Provider('1', '1', '1', '', '', '')
    p.add_rating('*****@*****.**', 3)
    p.add_rating('*****@*****.**', 2)
    p.add_rating('*****@*****.**', 5)
    assert (p.average_rating == (3 + 2 + 5) / (float(3)))
Exemplo n.º 16
0
def test_calc_average_rating_with_1_rating():
    p = Provider('1', '1', '1', '', '', '')
    p.add_rating('*****@*****.**', 3)
    assert (p.average_rating == 3)
Exemplo n.º 17
0
def test_remove_rating_of_non_existing_patient():
    p = Provider('1', '1', '1', '', '', '')
    checker = p.remove_rating('*****@*****.**')
    assert (checker == False)
    assert (list(p.rating.keys()) == [])
Exemplo n.º 18
0
def test_remove_rating_of_existing_patient():
    p = Provider('1', '1', '1', '', '', '')
    p.add_rating('*****@*****.**', 3)
    checker = p.remove_rating('*****@*****.**')
    assert (checker == True)
    assert (list(p.rating.keys()) == [])
Exemplo n.º 19
0
 def provider_obj(self):
     return Provider.get_by_id(long(self.provider))
Exemplo n.º 20
0
def test_get_availability_for_non_existing_centre_but_valid_date():
    p = Provider('1', '1', '1', '', '', '')
    # p.add_centre('rand')
    with pytest.raises(BookingError) as info:
        p.get_availability('centre', 2019, 12, 14)
Exemplo n.º 21
0
def test_add_int_between_0_and_5_rating():
    p = Provider('1', '1', '1', '', '', '')
    p.add_rating('*****@*****.**', 3)
    assert ('*****@*****.**' in p.rating.keys())
    assert (p.rating['*****@*****.**'] == 3)
Exemplo n.º 22
0
def prov_fixture1():
    p1 = Provider("*****@*****.**", "pwd", "smith", "john", 123, "GP")
    p2 = Provider("*****@*****.**", "pwd", "smith", "jane", 123, "Surgeon")
    p3 = Provider("*****@*****.**", "pwd", "sss", "jane", 123, "Physio")
    p4 = Provider("*****@*****.**", "pwd", "Strange", "Stephen", 123, "GP")
    return [p1, p2, p3, p4]
Exemplo n.º 23
0
def test_add_existing_centre():
    pp1 = Provider('trst', '123', 'sad', '12312', '2323', 'Blah')
    assert (pp1.centres == [])
    pp1.add_centre('Randwick Hospital')
    pp1.add_centre('randwick hospital')
    assert (len(pp1.centres) == 1)
Exemplo n.º 24
0
def test_add_non_existing_centre():
    p1 = Provider('*****@*****.**', '1234', 'McTester', 'Test', '124024114',
                  'Official Tester')
    assert (p1.centres == [])
    p1.add_centre('Randwick Hospital')
    assert ('Randwick Hospital'.lower() in p1.centres)
Exemplo n.º 25
0
def test_setters():
    p = Provider('*****@*****.**', '1234', 'McTester', 'Test', '124024114',
                 'Official Tester')

    p.email = '*****@*****.**'
    info = p.get_information()
    assert (info['email'] == '*****@*****.**')

    p.password = '******'
    info = p.get_information()
    assert (info['password'] != 'wooowthatsgreat'
            and info['password'] == 'WoooWThatsGreat')

    p.surname = 'MCTESTing'
    info = p.get_information()
    assert (info['surname'] == 'mctesting')

    p.given_name = 'TEEEESt'
    info = p.get_information()
    assert (info['given_name'] == 'teeeest')

    p.provider_no = '123123'
    info = p.get_information()
    assert (info['provider_no'] == '123123')

    p.service = 'OFFicial TESTer'
    info = p.get_information()
    assert (info['service'] == 'official tester')
Exemplo n.º 26
0
def test_calc_average_rating_with_out_ratings():
    p = Provider('1', '1', '1', '', '', '')
    assert (p.average_rating == 0)
    p.add_rating('*****@*****.**', 3)
    p.remove_rating('*****@*****.**')
    assert (p.average_rating == 0)
Exemplo n.º 27
0
def test_get_availability_invalid_date():
    p = Provider('1', '1', '1', '', '', '')
    with pytest.raises(DateTimeValidityError) as info:
        checker = p.get_availability('centre', 13, 22, 414)
    with pytest.raises(DateTimeValidityError) as info:
        checker = p.get_availability('centre', 'lol', 22, 414)
Exemplo n.º 28
0
def test_add_int_NOT_between_0_and_5_rating():
    p = Provider('1', '1', '1', '', '', '')
    assert (list(p.rating.keys()) == [])
    checker = p.add_rating('*****@*****.**', -1)
    assert (checker == False)
    assert (list(p.rating.keys()) == [])
Exemplo n.º 29
0
def test_get_availability_for_existing_centre_and_valid_date():
    p = Provider('1', '1', '1', '', '', '')
    p.add_centre('rand')
    with pytest.raises(DateTimeValidityError) as info:
        checker = p.get_availability('rand', 2018, 19, 220)
Exemplo n.º 30
0
def test_add_string_rating():
    p = Provider('1', '1', '1', '', '', '')
    assert (list(p.rating.keys()) == [])
    checker = p.add_rating('*****@*****.**', '1')
    assert (checker == False)
    assert (list(p.rating.keys()) == [])
Exemplo n.º 31
0
def test_add_rating_for_existing_patient():
    p = Provider('1', '1', '1', '', '', '')
    p.add_rating('*****@*****.**', 3)
    assert (p.rating['*****@*****.**'] == 3)
    p.add_rating('*****@*****.**', 5)
    assert (p.rating['*****@*****.**'] == 5)
Exemplo n.º 32
0
 def load_manager_view(self):
     providers = [provider for provider in Provider.all().fetch(100)]
     path = 'providers.html'
     markers = [[provider.name, provider.location.lat,provider.location.lon] for provider in providers]
     template_values = {'providers':providers,'count':len(providers),'markers':markers}
     self.write(self.get_rendered_html(path, template_values), 200)
Exemplo n.º 33
0
def prov_fixture2():
    p1 = Provider("*****@*****.**", "pwd", "smith", "john", 123, "GP")
    p2 = Provider("*****@*****.**", "pwd", "smith", "jane", 123, "GP")
    p3 = Provider("*****@*****.**", "pwd", "sss", "jane", 123, "Physio")
    return [p1, p2, p3]
Exemplo n.º 34
0
def vendor_mapper(member, role_name):
    fields = member['fields']
    tdc = TestDataCreationHandler()
    provider_obj = Provider.all().filter('airtable_id =', fields['Vendor ID']).get()
    if not provider_obj:
        provider_obj = Provider()
    provider_obj.name = fields['Vendor Name']
    provider_obj.phone_num = fields['Phone - Business Hours']
    dispatch_email = fields['Dispatch Email']
    provider_user = tdc.create_member(dispatch_email, fields['Primary Contact Name'], fields['Phone - Business Hours'], role_name)
    provider_obj.owner = provider_user
    provider_obj.location = map_address(fields['Address'])
    provider_obj.address = fields['Address']
    provider_obj.insurance = 'Hartford insurance'
    provider_obj.certifications = 'Class B Electrician license'
    provider_obj.reputation = 4.0
    provider_obj.airtable_id = fields['Vendor ID']
    provider_obj.put()