Пример #1
0
    def test_detail(self):
        url = Url(self.root)
        url.tail = 'foo'

        self.assertEqual(url.detail,
                         'http://test.com/path/to/paradise/foo/{id}',
                         'Detail url does not constructed properly!')
Пример #2
0
    def test_raises_error_if_tail_is_not_set(self):
        url = Url(self.root)

        # miss url.tail = 'foo'

        with self.assertRaises(NotImplementedError):
            url.list
Пример #3
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("-d", "--date", dest="date")
    parser.add_argument("-u", "--url", dest="url")
    args = parser.parse_args()

    date = Date.parser(os.environ.get('DATE', args.date))
    url = Url.stringify(os.environ.get('URL', args.url), date.year, date.month,
                        date.day)

    download = Download()

    with Storage(date) as storage:
        for hour in range(1, 25):
            storage.feed(hour, download.json(Url.stringify(url, hour)))
Пример #4
0
 def __init__(self, db_beacon_web_application, db_beacon_api, env):
     self.db_beacon_web_application = db_beacon_web_application
     self.db_beacon_api = db_beacon_api
     self.env = env
     self.html = Html(self)
     self.url_service = Url(
         self.db_beacon_web_application.get_field("url shortener"),
         self.db_beacon_web_application.get_field("url shortener key"))
     self.selected_beacon = None
     self.identifier = self.db_beacon_web_application.get_field(
         "identifier")
     self.picture_identifier = self.db_beacon_web_application.get_field(
         "picture identifier")
     self.form_template = self.db_beacon_web_application.get_field("form")
     self.table_template = self.db_beacon_web_application.get_field("table")
     self.fields = self.create_fields(self.form_template)
     self.readonly = self.db_beacon_web_application.get_field("read-only")
     self.room_finder = self.db_beacon_web_application.get_field(
         "roomfinder")
     self.advertisement_rate = self.db_beacon_web_application.get_field(
         "advertisement rate")
     self.transmission_power = self.db_beacon_web_application.get_field(
         "transmission power")
     self.drop_down_fields_transmission_power = self.db_beacon_web_application.get_field(
         "drop down transmission power")
     self.drop_down_fields_advertisement_rate = self.db_beacon_web_application.get_field(
         "drop down advertisement rate")
     self.image_path = self.db_beacon_web_application.get_field(
         "image path")
     self.advertisement_rate_converter = self.db_beacon_web_application.get_field(
         "advertisement rate converter")
     self.transmission_power_converter = self.db_beacon_web_application.get_field(
         "transmission power converter")
     self.advertisement_rate_converter_fields = self.db_beacon_web_application.get_field(
         "advertisement rate converter fields")
     self.transmission_power_converter_fields = self.db_beacon_web_application.get_field(
         "transmission power converter fields")
     self.maintenance_field = self.db_beacon_web_application.get_field(
         "maintenance field", "web api")
     self.timestamp_field = self.db_beacon_web_application.get_field(
         "timestamp field", "web api")
     self.len_s_beacon_id = self.db_beacon_web_application.get_field(
         "len s beacon id")
     self.action_update_beacon = "/update_beacon/"
     self.action_edit_beacon = "/edit_beacon/"
     self.newline = self.db_beacon_web_application.get_field("newline")
     self.update_action = False
     self.status = ""
     self.aes_cipher = AESCipher.keyFromVariable(utils.encryption.key)
Пример #5
0
 def test_defined_url(self):
     url = Url.stringify('url', 2019, 10, 15)
     self.assertEqual(url, 'url/2019/10/15')
Пример #6
0
 def test_undefined_url(self):
     with self.assertRaises(UrlException):
         url = Url.stringify('', 2019, 10, 15)
Пример #7
0
    def test_url_list(self):
        url = Url(self.root)
        url.tail = 'foo'

        self.assertEqual(url.list, 'http://test.com/path/to/paradise/foo',
                         'List url does not constructed properly!')
Пример #8
0
    def test_list_if_root_has_slash_in_the_end(self):
        root = self.root + '/'
        url = Url(root)
        url.tail = 'foo'

        self.assertEqual(url.list, 'http://test.com/path/to/paradise/foo')