text:
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyPost.Exceptions.General;
using EasyPost.Models.API;
using EasyPost.Tests._Utilities;
using EasyPost.Tests._Utilities.Annotations;
using EasyPost.Utilities.Annotations;
using Xunit;

namespace EasyPost.Tests.ModelsTests
{
    public class ShipmentTests : UnitTest
    {
        public ShipmentTests() : base("shipment")
        {
        }

        #region Tests

        #region Test CRUD Operations

        [Fact]
        [CrudOperations.Create]
        [Testing.Parameters]
        public async Task TestCreateWithTaxIdentifiers()
        {
            UseVCR("create_with_tax_identifiers");

            Dictionary<string, object> shipmentData = Fixtures.BasicShipment;
            shipmentData["tax_identifiers"] = new List<Dictionary<string, object>> { Fixtures.TaxIdentifier };

            Shipment shipment = await Client.Shipment.Create(shipmentData);

            Assert.IsType<Shipment>(shipment);
            Assert.StartsWith("shp_", shipment.Id);
            Assert.Equal("IOSS", shipment.TaxIdentifiers[0].TaxIdType);
        }

        // If the shipment was purchased with a USPS rate, it must have had its insurance set to `0` when bought
        // so that USPS doesn't automatically insure it so we could manually insure it here.
        [Fact]
        [CrudOperations.Create]
        [Testing.Function]
        public async Task TestInsure()
        {
            UseVCR("insure");

            Dictionary<string, object> shipmentData = Fixtures.OneCallBuyShipment;
            // Set to 0 so USPS doesn't insure this automatically and we can insure the shipment manually
            shipmentData["insurance"] = 0;

            Shipment shipment = await Client.Shipment.Create(shipmentData);

            shipment = await shipment.Insure(100);

            Assert.Equal("100.00", shipment.Insurance);
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestInsureWithNoId()
        {
            UseVCR("insure_with_no_id");

            Shipment shipment = await CreateFullShipment();
            shipment.Id = null;

            await Assert.ThrowsAsync<MissingPropertyError>(async () => await shipment.Insure(100));
        }

        [Fact]
        [CrudOperations.Read]
        [Testing.Function]
        public async Task TestGetSmartrates()
        {
            UseVCR("get_smartrates");

            Shipment shipment = await CreateBasicShipment();

            Assert.NotNull(shipment.Rates);

            List<Smartrate> smartRates = await shipment.GetSmartrates();
            Smartrate smartrate = smartRates.First();
            // Must compare IDs because one is a Rate object and one is a Smartrate object
            Assert.Equal(shipment.Rates[0].Id, smartrate.Id);
            Assert.NotNull(smartrate.TimeInTransit.Percentile50);
            Assert.NotNull(smartrate.TimeInTransit.Percentile75);
            Assert.NotNull(smartrate.TimeInTransit.Percentile85);
            Assert.NotNull(smartrate.TimeInTransit.Percentile90);
            Assert.NotNull(smartrate.TimeInTransit.Percentile95);
            Assert.NotNull(smartrate.TimeInTransit.Percentile97);
            Assert.NotNull(smartrate.TimeInTransit.Percentile99);
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestGetSmartratesWithNoId()
        {
            UseVCR("get_smartrates_with_no_id");

            Shipment shipment = await CreateBasicShipment();
            shipment.Id = null;

            await Assert.ThrowsAsync<MissingPropertyError>(async () => await shipment.GetSmartrates());
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Function]
        public async Task TestBuy()
        {
            UseVCR("buy");

            // buy with rate ID
            Shipment shipment = await CreateFullShipment();
            await shipment.Buy(shipment.LowestRate().Id);

            Assert.NotNull(shipment.PostageLabel);

            // buy with rate
            shipment = await CreateFullShipment();
            await shipment.Buy(shipment.LowestRate());

            Assert.NotNull(shipment.PostageLabel);
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestBuyWithNoId()
        {
            UseVCR("buy_with_no_id");

            Shipment shipment = await CreateFullShipment();
            shipment.Id = null;

            await Assert.ThrowsAsync<MissingPropertyError>(async () => await shipment.Buy(shipment.LowestRate().Id));
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestBuyWithNoRate()
        {
            UseVCR("buy_with_no_rate");

            Shipment shipment = await CreateFullShipment();

            await Assert.ThrowsAsync<MissingParameterError>(async () => await shipment.Buy(rate: null));
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestBuyWithNoRateId()
        {
            UseVCR("buy_with_no_rate_id");

            Shipment shipment = await CreateFullShipment();

            await Assert.ThrowsAsync<MissingParameterError>(async () => await shipment.Buy(rateId: null));
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestBuyWithCarbonOffset()
        {
            UseVCR("buy_with_carbon_offset");

            Shipment shipment = await CreateFullShipment();

            await shipment.Buy(shipment.LowestRate(), withCarbonOffset: true);

            Assert.NotNull(shipment.Fees);
            bool carbonOffsetIncluded = shipment.Fees.Any(fee => fee.Type == "CarbonOffsetFee");
            Assert.True(carbonOffsetIncluded);
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestBuyWithEndShipper()
        {
            UseVCR("buy_with_end_shipper");

            EndShipper endShipper = await Client.EndShipper.Create(Fixtures.CaAddress1);

            Shipment shipment = await CreateFullShipment();

            await shipment.Buy(shipment.LowestRate(), endShipperId: endShipper.Id);

            Assert.NotNull(shipment.PostageLabel);
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Function]
        public async Task TestGenerateLabel()
        {
            UseVCR("generate_label");

            Shipment shipment = await CreateOneCallBuyShipment();

            shipment = await shipment.GenerateLabel("ZPL");

            Assert.NotNull(shipment.PostageLabel.LabelZplUrl);
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestGenerateLabelWithNoId()
        {
            UseVCR("generate_label_with_no_id");

            Shipment shipment = await CreateOneCallBuyShipment();
            shipment.Id = null;

            await Assert.ThrowsAsync<MissingPropertyError>(async () => await shipment.GenerateLabel("ZPL"));
        }

        // Refunding a test shipment must happen within seconds of the shipment being created as test shipments naturally
        // follow a flow of created -> delivered to cycle through tracking events in test mode - as such anything older
        // than a few seconds in test mode may not be refundable.
        [Fact]
        [CrudOperations.Update]
        [Testing.Function]
        public async Task TestRefund()
        {
            UseVCR("refund");

            Shipment shipment = await CreateOneCallBuyShipment();

            shipment = await shipment.Refund();

            Assert.Equal("submitted", shipment.RefundStatus);
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestRefundWithNoId()
        {
            UseVCR("refund_with_no_id");

            Shipment shipment = await CreateOneCallBuyShipment();
            shipment.Id = null;

            await Assert.ThrowsAsync<MissingPropertyError>(async () => await shipment.Refund());
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Function]
        public async Task TestRegenerateRates()
        {
            UseVCR("regenerate_rates");

            Shipment shipment = await CreateFullShipment();

            await shipment.RegenerateRates();

            List<Rate> rates = shipment.Rates;

            Assert.NotNull(rates);
            foreach (Rate rate in rates)
            {
                Assert.IsType<Rate>(rate);
            }
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestRegenerateRatesWithNoId()
        {
            UseVCR("regenerate_rates_with_no_id");

            Shipment shipment = await CreateFullShipment();
            shipment.Id = null;

            await Assert.ThrowsAsync<MissingPropertyError>(async () => await shipment.RegenerateRates());
        }

        [Fact]
        [CrudOperations.Update]
        [Testing.Parameters]
        public async Task TestRegenerateRatesWithCarbonOffset()
        {
            UseVCR("regenerate_rates_with_carbon_offset");

            Shipment shipment = await Client.Shipment.Create(Fixtures.OneCallBuyShipment);
            List<Rate> baseRates = shipment.Rates;

            await shipment.RegenerateRates(withCarbonOffset: true);
            List<Rate> newRatesWithCarbon = shipment.Rates;

            Rate baseRate = baseRates.First();
            Rate newRateWithCarbon = newRatesWithCarbon.First();

            Assert.Null(baseRate.CarbonOffset);
            Assert.NotNull(newRateWithCarbon.CarbonOffset);
        }

        #endregion

        [Fact]
        [Testing.Function]
        public async Task TestLowestRate()
        {
            UseVCR("lowest_rate");

            Shipment shipment = await CreateFullShipment();

            // test lowest rate with no filters
            Rate lowestRate = shipment.LowestRate();
            Assert.Equal("First", lowestRate.Service);
            Assert.Equal("5.82", lowestRate.Price);
            Assert.Equal("USPS", lowestRate.Carrier);

            // test lowest rate with service filter (this rate is higher than the lowest but should filter)
            List<string> services = new() { "Priority" };
            lowestRate = shipment.LowestRate(null, services);
            Assert.Equal("Priority", lowestRate.Service);
            Assert.Equal("8.15", lowestRate.Price);
            Assert.Equal("USPS", lowestRate.Carrier);

            // test lowest rate with carrier filter (should error due to bad carrier)
            List<string> carriers = new() { "BAD_CARRIER" };
            Assert.Throws<FilteringError>(() => shipment.LowestRate(carriers));

            // test lowest rate with empty rate list
            shipment.Rates = new List<Rate>();
            Assert.Throws<FilteringError>(() => shipment.LowestRate(carriers));

            // test lowest rate with null rate list
            shipment.Rates = null;
            Assert.Throws<MissingPropertyError>(() => shipment.LowestRate(carriers));
        }

        [Fact]
        [Testing.Function]
        public async Task TestLowestSmartrate()
        {
            UseVCR("lowest_smartrate");

            Shipment shipment = await CreateBasicShipment();

            // test lowest smartrate with valid filters
            Smartrate lowestSmartrate = await shipment.LowestSmartrate(2, SmartrateAccuracy.Percentile90);
            Assert.Equal("Priority", lowestSmartrate.Service);
            Assert.Equal(8.15, lowestSmartrate.Rate);
            Assert.Equal("USPS", lowestSmartrate.Carrier);

            // test lowest smartrate with invalid filters (should error due to strict delivery_days)
            await Assert.ThrowsAsync<FilteringError>(async () => await shipment.LowestSmartrate(0, SmartrateAccuracy.Percentile90));

            // test lowest smartrate with invalid filters (should error due to bad delivery_accuracy)
            // this test is not needed in the C# CL because it uses enums for the accuracy (can't pass in an incorrect value)
        }

        [Fact]
        [Testing.Properties]
        public async Task TestForms()
        {
            UseVCR("forms");

            Shipment shipment = await CreateFullShipment();

            await shipment.Buy(shipment.LowestRate().Id);

            Assert.NotNull(shipment.Forms);

            foreach (Form? form in shipment.Forms)
            {
                Assert.NotNull(form.FormType);
                Assert.NotNull(form.FormUrl);
                Assert.True(form.SubmittedElectronically);
            }
        }

        #endregion

        private async Task<Shipment> CreateBasicShipment() => await Client.Shipment.Create(Fixtures.BasicShipment);

        private async Task<Shipment> CreateFullShipment() => await Client.Shipment.Create(Fixtures.FullShipment);

        private async Task<Shipment> CreateOneCallBuyShipment() => await Client.Shipment.Create(Fixtures.OneCallBuyShipment);
    }
}


text:
/**
 * @file    proxy_socket.h
 * @brief   支持代理的Socket类
 * @author  xiangwangfeng <xiangwangfeng@gmail.com>
 * @data	2011-4-23
 * @website www.xiangwangfeng.com
 */

#pragma once
#include <string>
#include "proxy_config.h"
#include "streaming_socket.h"

NAMESPACE_BEGIN(Http)

//支持代理的Socket类封装
class HTTP_CLASS ProxySocket
{
public:
	ProxySocket();
	ProxySocket(const std::string& remote_host_name,int port_number);
	~ProxySocket();

public:
	void	setHost(const std::string& remote_host_name,int port_number);
	static	void	setProxy(const ProxyConfig& proxy_config);

	bool	connect();
	bool	isConnected()	const	{	return	_socket.isConnected();}
	int		read(char* dst_buffer,int max_read_length);
	int		write(const char* source_buffer,int max_write_length);
	bool	writeAll(const char* source_buffer,int max_write_length);	//确保所有数据都被发送
	void	close();
private:
	bool	handShakeWithHttpProxy();
	bool	handShakeWithSock4Proxy();
	bool	handShakeWithSock5Proxy();
private:
	std::string			_host_name;
	int					_port_number;
	StreamingSocket		_socket;
	static ProxyConfig	_proxy_config;
};

NAMESPACE_END(Http)

redpajama_set_name: RedPajamaGithub


text:
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models

class Migration(SchemaMigration):

    def forwards(self, orm):
        # Adding field 'User.email'
        db.add_column(u'fandjango_user', 'email',
                      self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True),
                      keep_default=False)

        # Adding field 'User.locale'
        db.add_column(u'fandjango_user', 'locale',
                      self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True),
                      keep_default=False)

        # Adding field 'User.gender'
        db.add_column(u'fandjango_user', 'gender',
                      self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True),
                      keep_default=False)

        # Adding field 'User.extra_data'
        db.add_column(u'fandjango_user', 'extra_data',
                      self.gf('jsonfield.fields.JSONField')(default={}),
                      keep_default=False)

    def backwards(self, orm):
        # Deleting field 'User.email'
        db.delete_column(u'fandjango_user', 'email')

        # Deleting field 'User.locale'
        db.delete_column(u'fandjango_user', 'locale')

        # Deleting field 'User.gender'
        db.delete_column(u'fandjango_user', 'gender')

        # Deleting field 'User.extra_data'
        db.delete_column(u'fandjango_user', 'extra_data')

    models = {
        u'fandjango.oauthtoken': {
            'Meta': {'object_name': 'OAuthToken'},
            'expires_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'issued_at': ('django.db.models.fields.DateTimeField', [], {}),
            'token': ('django.db.models.fields.TextField', [], {})
        },
        u'fandjango.user': {
            'Meta': {'object_name': 'User'},
            'authorized': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
            'birthday': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
            'email': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
            'extra_data': ('jsonfield.fields.JSONField', [], {'default': '{}'}),
            'facebook_id': ('django.db.models.fields.BigIntegerField', [], {'unique': 'True'}),
            'facebook_username': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
            'gender': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
            'last_seen_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
            'locale': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
            'middle_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
            'oauth_token': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['fandjango.OAuthToken']", 'unique': 'True'})
        }
    }

    complete_apps = ['fandjango']


text:
package uk.ac.open.kmi.iserve.sal.events;

import java.util.Date;

/**
 * DocumentManagerEvent is an abstract class capturing all events related to the documents manager
 *
 * @author Carlos Pedrinaci (KMi - The Open University)
 * @since 05/09/2013
 */
public abstract class DocumentManagerEvent extends Event {

    public DocumentManagerEvent(Date date) {
        super(date);
    }
}


text:
'use strict';
angular.module('allUsersController', ['allUsersService','ngMaterial'])
.controller('allUsersController', function(Users,$location,$scope,$state,allUsers) {

    var self = this;

    var originatorEv;

    // Grab all the items from Cards Service
    Users.all()
    .then(function(data){
        self.userData = data.data;
        console.log(data)
    },function(data){
        console.log("An error occurred " + data);
    });

    self.goto = function(where){
        $state.go('peeps.details',{userId: where});
    };
});


text:
.. _nuenterpriseprofile:

nuenterpriseprofile
===========================================

.. class:: nuenterpriseprofile.NUEnterpriseProfile(bambou.nurest_object.NUMetaRESTObject,):

Enterprise profile, used to store an enterprise's policies, quota etc.

Attributes
----------

- ``bgp_enabled``: Enable BGP for this enterprise profile

- ``dhcp_lease_interval``: DHCP Lease Interval (in hours) to be used by an enterprise.

- ``vnf_management_enabled``: Enable VNF Management for this enterprise

- ``name`` (**Mandatory**): The unique name of the enterprise. Valid characters are alphabets, numbers, space and hyphen( - ).

- ``last_updated_by``: ID of the user who last updated the object.

- ``last_updated_date``: Time stamp when this object was last updated.

- ``web_filter_enabled``: Enable Web Filtering for this enterprise profile

- ``receive_multi_cast_list_id``: Readonly ID of the auto generated receive multicast list associated with this enterprise profile

- ``send_multi_cast_list_id``: Readonly ID of the auto generated send multicast list associated with this enterprise profile

- ``description``: A description of the enterprise/organisation profile.

- ``threat_prevention_management_enabled``: Enable Threat Prevention Management for enterprise

- ``allow_advanced_qos_configuration``: Controls whether this enterprise has access to advanced QoS settings.

- ``allow_gateway_management``: If set to true lets the enterprise admin create gateway templates and instances.

- ``allow_trusted_forwarding_class``: Controls whether QoS policies and templates created under this enterprise set the trusted flag to true

- ``allowed_forwarding_classes``: Allowed Forwarding Classes for this enterprise. Possible values are NONE, A, B, C, D, E, F, G, H, .

- ``floating_ips_quota``: Quota set for the number of floating IPs to be used by an enterprise.

- ``embedded_metadata``: Metadata objects associated with this entity. This will contain a list of Metadata objects if the API request is made using the special flag to enable the embedded Metadata feature. Only a maximum of Metadata objects is returned based on the value set in the system configuration.

- ``enable_application_performance_management``: Enable DPI for this enterprise

- ``enable_oam_connectivity_statistics_collection``: Enables the collection of OAM Connectivity Statistics in the Elastic DB.

- ``encryption_management_mode``: encryption management mode for this enterprise Possible values are DISABLED, MANAGED, .

- ``entity_scope``: Specify if scope of entity is Data center or Enterprise level

- ``forwarding_class``: Represents the List of forwarding classes and their load balancing capability.

- ``creation_date``: Time stamp when this object was created.

- ``owner``: Identifies the user that has created this object.

- ``external_id``: External object ID. Used for integration with third party systems

Children
--------

================================================================================================================================================               ==========================================================================================
**class**                                                                                **fetcher**

:ref:`nupermission.NUPermission<nupermission>`                                                                                ``permissions``
:ref:`numetadata.NUMetadata<numetadata>`                                                                                ``metadatas``
:ref:`nuglobalmetadata.NUGlobalMetadata<nuglobalmetadata>`                                                                                ``global_metadatas``
:ref:`nuenterprise.NUEnterprise<nuenterprise>`                                                                                ``enterprises``
:ref:`numulticastlist.NUMultiCastList<numulticastlist>`                                                                                ``multi_cast_lists``
:ref:`nueventlog.NUEventLog<nueventlog>`                                                                                ``event_logs``
================================================================================================================================================               ==========================================================================================

Parents
--------

- :ref:`nume.NUMe<nume>`


text:
package com.google.javascript.jscomp;

/**
 * Tests for {@link ObjectPropertyStringPostprocess}.
 *
 */
public class ObjectPropertyStringPostprocessTest extends CompilerTestCase {
  @Override
  protected CompilerPass getProcessor(final Compiler compiler) {
    return new ObjectPropertyStringPostprocess(compiler);
  }

  @Override
  protected int getNumRepetitions() {
    return 1;
  }

  public void testFooDotBar() {
    testPass("goog.global, foo.bar", "foo, 'bar'");
  }

  public void testFooGetElemBar() {
    testPass("goog.global, foo[bar]", "foo, bar");
  }

  public void testFooBar() {
    testPass("goog.global, foo$bar", "goog.global, 'foo$bar'");
  }

  private void testPass(String input, String expected) {
    test("new JSCompiler_ObjectPropertyString(" + input + ")",
         "new JSCompiler_ObjectPropertyString(" + expected + ")");
  }
}