Пример #1
0
 def tearDownClass(cls):
     setting = Setting.instance()
     setting.delete_user('test_username')
     try:
         shutil.rmtree('./sessions')
     except:  # already deleted in delete_user
         pass
     Setting.destroy_instance()
Пример #2
0
    def test_save_setting(self):
        settings = Setting.instance()
        settings.set_active_user('test_username')
        settings.set('account_id', 'test_account_id')
        settings.set('devicestring', 'test_devicestring')

        loaded_settings = settings.load_user_settings()
        self.assertEqual(loaded_settings['account_id'], 'test_account_id')
        self.assertEqual(loaded_settings['devicestring'], 'test_devicestring')
Пример #3
0
 def test_setting_with_invalid_options(self):
     with self.assertRaises(SettingsException):
         Setting.create_instance('file', {})
Пример #4
0
 def test_setting_with_no_handler(self):
     with self.assertRaises(SettingsException):
         Setting.instance()
Пример #5
0
 def test_delete_user(self):
     Setting.create_instance('file', {
         'base_directory': './sessions',
     })
     settings = Setting.instance()
     settings.delete_user('test_username')
Пример #6
0
 def test_save_invalid_key(self):
     settings = Setting.instance()
     settings.set_active_user('test_username')
     with self.assertRaises(SettingsException):
         settings.set('invalid_key', 'invalid_value')
Пример #7
0
 def test_call_load_user_setting_before_set_active_user(self):
     settings = Setting.instance()
     with self.assertRaises(SettingsException):
         settings.set('some_key', 'some value')
Пример #8
0
 def test_new_setting(self):
     setting = Setting.instance()
     setting.set_active_user('test_username')
     self.assertIsNotNone(setting)
Пример #9
0
 def test_illegal_way_to_make_instance(self):
     with self.assertRaises(SettingsException):
         Setting()
Пример #10
0
 def setUpClass(cls):
     Setting.create_instance('file', {
         'base_directory': './sessions',
     })
Пример #11
0
"""
make a settings.py file.

# filename: settings.py
username = '******'
password = '******'
"""

from __future__ import unicode_literals, print_function

from pyinstagram.instagram import Instagram
from pyinstagram.setting import Setting
from settings import username, password

Setting.create_instance('file', {'base_directory': './sessions'})

instagram = Instagram(Setting.instance())
instagram.set_user(username, password)
instagram.login()

print('instagram', instagram)
Пример #12
0
 def setUp(self):
     # a new Instagram instance for every test methods
     self.instagram = Instagram(Setting.instance())
Пример #13
0
 def tearDownClass(cls):
     Setting.instance().delete_user('testuser')
     os.removedirs('./sessions')