def setUp(self):
     self.u = user.build()
     self.u.attr["email"] = "*****@*****.**"
     self.u.attr["name"] = "Hoge"
     self.u.attr["password"] = "******"
     self.patcher = mock.patch('model.project.project.name',
                               return_value="test_user")
     self.mock_name = self.patcher.start()
     user.migrate()
     self.u.save()
Esempio n. 2
0
 def setUp(self):
     self.u = user()
     self.u.attr["email"] = "*****@*****.**"
     self.u.attr["favorite"] = 1
     self.u.attr["password"] = "******"
     self.patcher = mock.patch('model.project.project.name',
                               return_value="test_db_artist")
     self.mock_name = self.patcher.start()
     user.migrate()
     self.u.save()
 def setUp(self):
     self.u = user()
     self.u.attr["email"] = "*****@*****.**"
     self.u.attr["genre"] = "rock"
     self.u.attr["sex"] = "female"
     self.u.attr["fan_class"] = "twenties"
     self.u.attr["artist_name"] = "爆弾ジョニー"
     self.u.attr["favorite"] = None
     self.u.attr["password"] = "******"
     self.patcher = mock.patch('model.project.project.name',
                               return_value="test_db_artist")
     self.mock_name = self.patcher.start()
     user.migrate()
     self.u.save()
Esempio n. 4
0
        # mypage 表示
        (r"/mypageUser", UserMyPageHandler),
        (r"/mypageArtist", ArtistMyPageHandler),

        # search
        (r"/search", SearchHandler),
        # searchResults
        (r"/searchResults", SearchResultsHandler),
    ],
    template_path=os.path.join(os.getcwd(), "templates"),
    static_path=os.path.join(os.getcwd(), "static"),
    # cookieの暗号化キー(システムごとにランダムな文字列を設定する)
    cookie_secret="x-D-#i&0S?R6w9qEsZB8Vpxw@&t+B._$",
)

if __name__ == "__main__":
    args = sys.argv
    if len(args) > 1:
        if args[1] == "migrate":
            user.migrate()
        if args[1] == "db_cleaner":
            user.db_cleaner()
        if args[1] == "help":
            print("usage: python server.py migrate # prepare DB")
            print("usage: python server.py db_cleaner # remove DB")
            print("usage: python server.py # run web server")
    else:
        application.listen(3000, "0.0.0.0")
        tornado.ioloop.IOLoop.instance().start()
Esempio n. 5
0
 def setUp(self):
     self.f = user.build()
     self.f.attr["name"] = "Hoge"
     self.f.attr["password"] = "******"
     user.migrate()
     self.f.save()
Esempio n. 6
0
    def test_artist_all(self):

        user.migrate()

        # 全一致のデータ
        u1 = user()
        u1.attr["email"] = "*****@*****.**"
        u1.attr["genre"] = "rock"
        u1.attr["sex"] = "female"
        u1.attr["fan_class"] = "twenties"
        u1.attr["artist_name"] = "爆弾ジョニー"
        u1.attr["password"] = "******"
        artist_1 = u1.save()
        # genre, sex 一致のデータ
        u2 = user()
        u2.attr["email"] = "*****@*****.**"
        u2.attr["genre"] = "rock"
        u2.attr["sex"] = "female"
        u2.attr["fan_class"] = "thirties"
        u2.attr["artist_name"] = "ONIGAWARA"
        u2.attr["password"] = "******"
        artist_2 = u2.save()
        # sex, fan_class 一致のデータ
        u3 = user()
        u3.attr["email"] = "*****@*****.**"
        u3.attr["genre"] = "alternative"
        u3.attr["sex"] = "female"
        u3.attr["fan_class"] = "twenties"
        u3.attr["artist_name"] = "SAMURAIMANZGROOVE"
        u3.attr["password"] = "******"
        artist_3 = u3.save()
        # genre, fan_class 一致のデータ
        u4 = user()
        u4.attr["email"] = "*****@*****.**"
        u4.attr["genre"] = "rock"
        u4.attr["sex"] = "male"
        u4.attr["fan_class"] = "twenties"
        u4.attr["artist_name"] = "ビレッジマンズストア"
        u4.attr["password"] = "******"
        artist_4 = u4.save()
        # genre 一致のデータ
        u5 = user()
        u5.attr["email"] = "*****@*****.**"
        u5.attr["genre"] = "rock"
        u5.attr["sex"] = "male"
        u5.attr["fan_class"] = "thirties"
        u5.attr["artist_name"] = "みそっかす"
        u5.attr["password"] = "******"
        artist_5 = u5.save()
        # sex 一致のデータ
        u6 = user()
        u6.attr["email"] = "*****@*****.**"
        u6.attr["genre"] = "alternative"
        u6.attr["sex"] = "female"
        u6.attr["fan_class"] = "forties"
        u6.attr["artist_name"] = "SOPHIA"
        u6.attr["password"] = "******"
        artist_6 = u6.save()
        # fan_class 一致のデータ
        u7 = user()
        u7.attr["email"] = "*****@*****.**"
        u7.attr["genre"] = "alternative"
        u7.attr["sex"] = "male"
        u7.attr["fan_class"] = "twenties"
        u7.attr["artist_name"] = "バックドロップシンデレラ"
        u7.attr["password"] = "******"
        artist_7 = u7.save()
        # 一個も一致しないデータ
        u8 = user()
        u8.attr["email"] = "*****@*****.**"
        u8.attr["genre"] = "alternative"
        u8.attr["sex"] = "male"
        u8.attr["fan_class"] = "thirties"
        u8.attr["artist_name"] = "八十八ヶ所巡礼"
        u8.attr["password"] = "******"
        artist_8 = u8.save()
        # ユーザーのデータ
        u9 = user()
        u9.attr["email"] = "*****@*****.**"
        u9.attr["password"] = "******"
        suporter_1 = u9.save()
        u10 = user()
        u10.attr["email"] = "*****@*****.**"
        u10.attr["password"] = "******"
        suporter_2 = u10.save()

        artist_all = user.artist_all()
        self.assertEqual(len(artist_all), 8)
Esempio n. 7
0
    def test_search_artists(self):

        genre = "rock"
        sex = "female"
        fan_class = "twenties"

        user.migrate()

        # 全一致のデータ
        u1 = user()
        u1.attr["email"] = "*****@*****.**"
        u1.attr["genre"] = "rock"
        u1.attr["sex"] = "female"
        u1.attr["fan_class"] = "twenties"
        u1.attr["artist_name"] = "爆弾ジョニー"
        u1.attr["password"] = "******"
        artist_1 = u1.save()
        # genre, sex 一致のデータ
        u2 = user()
        u2.attr["email"] = "*****@*****.**"
        u2.attr["genre"] = "rock"
        u2.attr["sex"] = "female"
        u2.attr["fan_class"] = "thirties"
        u2.attr["artist_name"] = "ONIGAWARA"
        u2.attr["password"] = "******"
        artist_2 = u2.save()
        # sex, fan_class 一致のデータ
        u3 = user()
        u3.attr["email"] = "*****@*****.**"
        u3.attr["genre"] = "alternative"
        u3.attr["sex"] = "female"
        u3.attr["fan_class"] = "twenties"
        u3.attr["artist_name"] = "SAMURAIMANZGROOVE"
        u3.attr["password"] = "******"
        artist_3 = u3.save()
        # genre, fan_class 一致のデータ
        u4 = user()
        u4.attr["email"] = "*****@*****.**"
        u4.attr["genre"] = "rock"
        u4.attr["sex"] = "male"
        u4.attr["fan_class"] = "twenties"
        u4.attr["artist_name"] = "ビレッジマンズストア"
        u4.attr["password"] = "******"
        artist_4 = u4.save()
        # genre 一致のデータ
        u5 = user()
        u5.attr["email"] = "*****@*****.**"
        u5.attr["genre"] = "rock"
        u5.attr["sex"] = "male"
        u5.attr["fan_class"] = "thirties"
        u5.attr["artist_name"] = "みそっかす"
        u5.attr["password"] = "******"
        artist_5 = u5.save()
        # sex 一致のデータ
        u6 = user()
        u6.attr["email"] = "*****@*****.**"
        u6.attr["genre"] = "alternative"
        u6.attr["sex"] = "female"
        u6.attr["fan_class"] = "forties"
        u6.attr["artist_name"] = "SOPHIA"
        u6.attr["password"] = "******"
        artist_6 = u6.save()
        # fan_class 一致のデータ
        u7 = user()
        u7.attr["email"] = "*****@*****.**"
        u7.attr["genre"] = "alternative"
        u7.attr["sex"] = "male"
        u7.attr["fan_class"] = "twenties"
        u7.attr["artist_name"] = "バックドロップシンデレラ"
        u7.attr["password"] = "******"
        artist_7 = u7.save()
        # 一個も一致しないデータ
        u8 = user()
        u8.attr["email"] = "*****@*****.**"
        u8.attr["genre"] = "alternative"
        u8.attr["sex"] = "male"
        u8.attr["fan_class"] = "thirties"
        u8.attr["artist_name"] = "八十八ヶ所巡礼"
        u8.attr["password"] = "******"
        artist_8 = u8.save()

        self.assertEqual(u1.attr["id"], 1)
        self.assertEqual(u2.attr["id"], 2)
        self.assertEqual(u3.attr["id"], 3)
        self.assertEqual(u4.attr["id"], 4)
        self.assertEqual(u5.attr["id"], 5)
        self.assertEqual(u6.attr["id"], 6)
        self.assertEqual(u7.attr["id"], 7)
        self.assertEqual(u8.attr["id"], 8)

        artist_list = user.search_artists(genre, sex, fan_class)
        self.assertEqual(len(artist_list), 1)
        self.assertTrue(type(artist_list[0]) is user)

        artist_list_gs = user.search_artists(genre, sex, '')
        self.assertEqual(len(artist_list_gs), 2)
        self.assertTrue(type(artist_list_gs[0]) is user)
        self.assertTrue(type(artist_list_gs[1]) is user)

        artist_list_sf = user.search_artists('', sex, fan_class)
        self.assertEqual(len(artist_list_sf), 2)
        self.assertTrue(type(artist_list_sf[0]) is user)
        self.assertTrue(type(artist_list_sf[1]) is user)

        artist_list_gf = user.search_artists(genre, '', fan_class)
        self.assertEqual(len(artist_list_gf), 2)
        self.assertTrue(type(artist_list_gf[0]) is user)
        self.assertTrue(type(artist_list_gf[1]) is user)

        artist_list_g = user.search_artists(genre, '', '')
        self.assertEqual(len(artist_list_g), 4)
        self.assertTrue(type(artist_list_g[0]) is user)
        self.assertTrue(type(artist_list_g[1]) is user)
        self.assertTrue(type(artist_list_g[2]) is user)
        self.assertTrue(type(artist_list_g[3]) is user)

        artist_list_s = user.search_artists('', sex, '')
        self.assertEqual(len(artist_list_s), 4)
        self.assertTrue(type(artist_list_s[0]) is user)
        self.assertTrue(type(artist_list_s[1]) is user)
        self.assertTrue(type(artist_list_s[2]) is user)
        self.assertTrue(type(artist_list_s[3]) is user)

        artist_list_f = user.search_artists('', '', fan_class)
        self.assertEqual(len(artist_list_f), 4)
        self.assertTrue(type(artist_list_f[0]) is user)
        self.assertTrue(type(artist_list_f[1]) is user)
        self.assertTrue(type(artist_list_f[2]) is user)
        self.assertTrue(type(artist_list_f[3]) is user)

        artist_list_all = user.search_artists('', '', '')
        self.assertEqual(len(artist_list_all), 8)
        self.assertTrue(type(artist_list_all[0]) is user)
        self.assertTrue(type(artist_list_all[1]) is user)
        self.assertTrue(type(artist_list_all[2]) is user)
        self.assertTrue(type(artist_list_all[3]) is user)
        self.assertTrue(type(artist_list_all[4]) is user)
        self.assertTrue(type(artist_list_all[5]) is user)
        self.assertTrue(type(artist_list_all[6]) is user)
        self.assertTrue(type(artist_list_all[7]) is user)