Exemple #1
0
 def test_company_model_creation_2(self):
     c = Company.Company(*TestModels.test_company)
     db.session.add(c)
     db.session.commit()
     result = Company.find_by_id(100)
     # company was found
     assert (len(result) > 0)
Exemple #2
0
def create_company():
    data = request.get_json()
    db_session = get_session()

    if validate_create_company_data(data):
        return jsonify({'status': 'error', 'message': 'data is not invalid'})

    try:
        if not db_session.query(Company).filter(
                Company.name == data['name']).all():
            if data['detail'] == '':
                data['detail'] = 'Details are not available'

            new_company = Company(name=data['name'], logo=data['logo'], \
              established=data['established'], website=data['website'], type=data['type'], detail=data['detail'])

            db_session.add(new_company)
            db_session.commit()
    except Exception as error:
        return jsonify({
            'status': 'error',
            'message': 'could not add data into databae'
        })

    db_session.close()
    return jsonify({'status': 'success'})
Exemple #3
0
def enterpriseInfoSave(req):
    """
    企业信息保存!
    :param req:
    :return:
    """
    enterpriseType = req.POST["enterpriseType"]
    enterprise = Company.objects.filter(companyName=enterpriseType)
    if req.POST["radioVal"] == "1":
        isShow = True
    else:
        isShow = False
    if enterprise.exists():
        return HttpResponse(2)
    companyId = uuid.uuid1()  # 生成36位随机数
    try:
        with transaction.atomic():  # 事务的使用,包含的内容一旦出错,则保存的信息全部撤回
            company = Company(companyId=companyId,
                              companyName=enterpriseType,
                              isShow=isShow)
            company.save()
            i = 0
            while i < len(req.POST) - 2:
                enterpriseInfoNum = "enterprise" + str(i)
                enterpriseInfo = req.POST[enterpriseInfoNum]
                dataType = DataType(dataTypeId=uuid.uuid1(),
                                    companyId_id=companyId,
                                    dataName=enterpriseInfo)
                dataType.save()
                i = i + 1
                print enterpriseInfo
            return HttpResponse(1)
    except Exception as err:
        print err
        return HttpResponse(0)
Exemple #4
0
    def create_company(jwt):
        request_value = request.get_json()
        if request_value is None:
            abort(400)

        properties = ['name', 'description', 'imageBase64', 'state', 'city']
        for prop in properties:
            if prop not in request_value:
                abort(400)

        if request_value['name'] is None:
            abort(400)

        if request_value['state'] is None or request_value['city'] is None:
            abort(400)

        company = Company(
            request_value['name'],
            request_value['description'],
            request_value['imageBase64'],
            request_value['state'],
            request_value['city']
        )
        company.insert()

        return jsonify({
            'status_code': 200,
            'company': company.format(),
            'message': 'The company was successfully created',
            'success': True,
        })
Exemple #5
0
    def setUp(self):
        database_name = 'capstone_test'
        database_path = 'postgresql://jaimeaznar@{}/{}'.format(
            'localhost:5432', database_name)
        self.app = create_app()
        self.app.config['WTF_CSRF_ENABLED'] = False
        self.client = self.app.test_client
        setup_db(self.app, database_path)

        db.session.close()
        db.drop_all()
        db.create_all()

        # mock company
        self.company = Company(name='test company',
                               city='test city',
                               state='test state',
                               address='test address',
                               phone='12345')
        self.company.insert()

        # mock product
        self.product = Product(name='test product',
                               image='static/img/tomahawk.jpg',
                               description='test description',
                               company_id=1)
        self.product.insert()
Exemple #6
0
    def test_game_companies(self):
        dev1 = Company(name="Boss Interactive")
        dev2 = Company(name="Epic Entertainment")
        pub = Company(name="We love money")
        g = Game(name="Call of brewty: Modern coffee")
        dev1.developed_games.append(g)
        dev2.developed_games.append(g)
        pub.published_games.append(g)
        self.session.add(dev1)
        self.session.add(dev2)
        self.session.add(pub)
        self.session.add(g)

        result = self.session.query(Game).filter_by(
            name="Call of brewty: Modern coffee").first()
        self.assertEqual(len(result.developers), 2)
        self.assertEqual(len(result.publishers), 1)
Exemple #7
0
 def test_callingGetAvailableSchemesCallsFilterOnCompetenceFieldCollectionToCompanyRelationWithCompanyPkAsArgument(
         self):
     company = Company()
     company.pk = 8
     with mock.patch.object(CompetenceFieldCollectionToCompanyRelation,
                            'objects') as query_mock:
         company.getAvailableSchemes()
         query_mock.filter.assert_called_with(company__pk=company.pk)
Exemple #8
0
 def test_company_model_creation_1(self):
     c = Company.Company(*self.test_company)
     d = c.to_dict()
     for k in TestModels.test_company_dict:
         if k == "date_founded":
             assert (str(d[k]).split()[0] == str(
                 TestModels.test_company_dict[k]))
         else:
             assert (d[k] == TestModels.test_company_dict[k])
Exemple #9
0
 def test_game_model_creation_1(self):
     c = Company.Company(*TestModels.test_company)
     db.session.add(c)
     db.session.commit()
     g = Game.Game(*TestModels.test_game)
     db.session.add(g)
     db.session.commit()
     result = Game.Game.query.all()
     assert (len(result) == 1)
Exemple #10
0
    def test_company_published(self):
        c = Company(name="Righteous")
        g1 = Game(name="Shmalo 2")
        c.published_games.append(g1)
        self.session.add(c)
        self.session.add(g1)

        result = self.session.query(Company).filter(Company.name == "Righteous").first()
        self.assertEqual(len(result.published_games), 1)
Exemple #11
0
    def test_company_constructor_2(self):
        """Test construction of a new company instance"""

        example1 = Company("id", "name", "summary", "people",
                           "city", "finorgs", "twitter", "website", "logo")

        self.assertEqual(example1.financial_orgs, "finorgs")
        self.assertEqual(example1.twitter, "twitter")
        self.assertEqual(example1.website, "website")
        self.assertEqual(example1.logo_url, "logo")
Exemple #12
0
def insert_company():
    companies = pandas.read_csv('company.csv', quotechar='"', na_filter=False)
    for i in range(len(companies)):
        company = Company( companies['name'][i],
            companies['location'][i],
            companies['description'][i],
            companies['org_type'][i],
            companies['logo'][i])
        db.session.add(company)
    db.session.commit()
Exemple #13
0
def get_ftse_companies(url):
    companies = []
    table = pd.read_html(url)[3]
    for index, row in table.iterrows():
        company = Company(row['EPIC'])
        company.name = row['Company']
        company.sector = row[
            'FTSE Industry Classification Benchmark sector[12]']
        companies.append(company)
    return companies
Exemple #14
0
    def test_company_commits(self):
        company = Company(
            'CASS', 'Cass Information Systems, Inc', 'NMS', 'USD', 'USA', '51,29', '50.82',
            '+2.42%', '59.09', '52.06', '2.07', '0.00', '51.20-52.22', '+4,24%', '+3.80%',
            '22222', '27743', '585.15M')
        db.session.add(company)
        db.session.commit()

        # assert company is in db
        self.assertIn(company, db.session)
Exemple #15
0
 def test_callingGetEmployeesCallsFilterOnEmployeeWithCompanyPkAsArgumentAndIsMangerEqualToTrue(
         self):
     employee = Employee()
     company = Company()
     company.pk = 8
     employee.company = company
     with mock.patch.object(Employee, 'objects') as query_mock:
         employee.getEmployees()
         query_mock.filter.assert_called_with(company__pk=company.pk,
                                              is_manager=True)
Exemple #16
0
 def register(self, email, pwd, description):
     from models import Company
     from devjobs import db
     from hashlib import sha512
     try:
         c = Company(email, sha512(pwd).hexdigest(), description)
         db.session.add(c)
         db.session.commit()
         return True
     except Exception as e:
         return False
Exemple #17
0
    def test_company_insert(self):
        company_repr = {"name": "SomeCompany", "city": "Austin", "country": "US",
                        "deck": "Specializes in making dope games",
                        "date_founded": parser.parse("2016-02-01 00:00:00")}
        c = Company(**company_repr)
        self.session.add(c)

        r = self.session.query(Company).filter(Company.city == "Austin").first()
        self.assertEqual(r.name, "SomeCompany")
        self.assertEqual(r.country, "US")
        self.assertEqual(r.date_founded, datetime(2016, 2, 1, 0, 0))
Exemple #18
0
    def test_company_returns(self):
        company = Company(
            'CASS', 'Cass Information Systems, Inc', 'NMS', 'USD', 'USA', '51,29', '50.82',
            '+2.42%', '59.09', '52.06', '2.07', '0.00', '51.20-52.22', '+4,24%', '+3.80%',
            '22222', '27743', '585.15M')
        db.session.add(company)
        db.session.commit()

        # assert it retuns correct data
        self.assertEqual(
            '<Company \'Cass Information Systems, Inc\'>', str(company.query.first()))
Exemple #19
0
    def test_company_repr_2(self):
        """Test __repr__ methond of company class"""

        example2 = Company("id1", "Wetpaint",
                           ("Wetpaint is a technology platform company that uses its proprietary"
                            + " state-of-the-art technology and expertise in social media to build"
                            + " and monetize audiences for digital publishers."), "person1",
                           "San Francisco", "Youniversity Ventures", "wetpaint",
                           "http://wetpaint.com", "logo_url")

        self.assertEqual(example2.__repr__(), "<Company 'Wetpaint'>")
def add_rev():
  
  standard = request.args.get("standard")
  points = request.args.get("points")
  additional_info = request.args.get("additional_info")

  rev = Company(standard, points, additional_info)
  db_session.add(rev)
  db_session.commit()

  return redirect(url_for('database'))
Exemple #21
0
def get_snp_500_companies(url):
    companies = []
    table = pd.read_html(url)[0]
    for index, row in table.iterrows():
        company = Company(row['Symbol'])
        company.name = row['Security']
        company.sector = row['GICS Sector']
        company.industry = row['GICS Sub Industry']
        company.date_added = row['Date first added']
        companies.append(company)
    return companies
Exemple #22
0
def company_ws_count():
    try:
        with db.DbContext() as connection:
            cursor = connection.cursor()
            cursor.execute(
                "select company,count(*) from internship group by company")
            rows = cursor.fetchall()
            company_pro_lst = [Company(*row) for row in rows]
            _view_company_count(company_pro_lst)
    except Exception as e:
        print(str(e))
Exemple #23
0
    def test_company_constructor_1(self):
        """Test construction of a new company instance"""

        example1 = Company("id", "name", "summary", "people",
                           "city", "finorgs", "twitter", "website", "logo")

        self.assertEqual(example1.company_id, "id")
        self.assertEqual(example1.name, "name")
        self.assertEqual(example1.summary, "summary")
        self.assertEqual(example1.people, "people")
        self.assertEqual(example1.city, "city")
Exemple #24
0
    def test_company_dictionary_2(self):
        """Test dictionary method of company class"""

        example1 = Company("id", "name", "summary", "people",
                           "city", "finorgs", "twitter", "website", "logo")
        dict_rep = example1.dictionary()

        self.assertEqual(dict_rep['financial_orgs'], "finorgs")
        self.assertEqual(dict_rep['twitter'], "twitter")
        self.assertEqual(dict_rep['website'], "website")
        self.assertEqual(dict_rep['logo_url'], "logo")
Exemple #25
0
def employee_companies():
    try:
        companies = Stem_Employee_Demographics.query.with_entities(
            Stem_Employee_Demographics.Company,
            Stem_Employee_Demographics.Type).distinct().order_by(
                Stem_Employee_Demographics.Company)
        c = []
        for x in companies:
            c.append(Company(x.Company, x.Type))
        return jsonify([x.serialize() for x in c])
    except Exception as e:
        return (str(e))
Exemple #26
0
 def delete(self, request, company_id):
     """
     Handling DELETE method.
     args
         request: Request to View.
         company_id: id of company to be deleted.
     :return: HttpResponse with code 201 if company is deleted.
     """
     company = Company()
     company.delete_company(company_id)
     data = serializers.serialize("json", Company.get_company())
     return HttpResponse(data)
Exemple #27
0
def scrape_companies_data(
    company_names: List[str],
    use_cache: bool = False,
    n: int = 2147483647,
    skip_companies: Set[str] = set()
) -> Tuple[List[Company], List[FailedCompanyError]]:
    errors = []
    output_data = []

    for i, company_name in enumerate(company_names):
        if i >= n:
            break

        if company_name in skip_companies:
            print(f'[INFO] Skip scraping {company_name}')
            continue

        try:
            company_id = company_name.replace(' ', '_').lower()
            company = Company(id=company_id)
            overview_url, reviews_url = scraper.get_glassdoor_urls(
                company_name)
            print('[INFO]', company_name, overview_url, reviews_url)
            if overview_url is None or reviews_url is None:
                raise Exception(
                    f'Cannot find both URLs for "{company_name}": {overview_url} {reviews_url}'
                )

            reviews_data = scraper.scrape(reviews_url,
                                          f'{company_name}_reviews.html',
                                          scraper.get_reviews_data)
            overview_data = scraper.scrape(overview_url,
                                           f'{company_name}_overview.html',
                                           scraper.get_overview_data)
            data = {
                'name': company_name,
                'overview_url': overview_url,
                'reviews_url': reviews_url,
                'linkedin_url': scraper.get_linkedin_url(company_name),
            }
            data.update(reviews_data)
            data.update(overview_data)
            company.update_data(data)
            output_data.append(company)
        except Exception as e:
            print(f'[FAIL] caught exception when parsing "{company_name}"')
            errors.append(
                FailedCompanyError(
                    company_name=company_name,
                    exception=e,
                ))

    return output_data, errors
Exemple #28
0
def new_user_company():
    form = CompanyForm()
    if form.validate_on_submit():
        company = Company(name=form.name.data, commercial_business=form.commercial_business.data,
                        employees=form.employees.data, company_seniority=form.company_seniority.data,
                        annual_sales=form.annual_sales.data, address=form.address.data,
                        company_phone=form.company_phone.data, user=current_user)
        db.session.add(company)
        db.session.commit()
        flash('Ya casi esta listo tu solicitud', 'is-success')
        return redirect(url_for('credit_request'))
    return render_template('user_company.html', title="Datos Comerciales", form=form)
Exemple #29
0
    def test_company_dictionary_1(self):
        """Test dictionary method of company class"""

        example1 = Company("id", "name", "summary", "people",
                           "city", "finorgs", "twitter", "website", "logo")
        dict_rep = example1.dictionary()

        self.assertEqual(dict_rep['company_id'], "id")
        self.assertEqual(dict_rep['name'], "name")
        self.assertEqual(dict_rep['summary'], "summary")
        self.assertEqual(dict_rep['people'], "people")
        self.assertEqual(dict_rep['city'], "city")
Exemple #30
0
    def test_company_people(self):
        c = Company(name="CoolCats")
        p = Person(name="Elise")
        self.session.add(c)
        self.session.add(p)

        self.assertTrue(len(c.people) < 1)
        c.people.append(p)
        self.session.add(c)

        result = self.session.query(Company).filter_by(name="CoolCats").first()
        p_again = result.people[0]
        self.assertEqual(p_again.name, "Elise")